//package com.amigo.online.provider.search.rocketmq.consumer;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import javax.annotation.Resource;
//
//import org.apache.solr.client.solrj.SolrClient;
//import org.apache.solr.common.SolrDocument;
//import org.apache.solr.common.SolrInputDocument;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//
//import com.amigo.online.common.param.result.MusicInfo;
//import com.amigo.online.provider.search.rocketmq.PushMessage;
//import com.amigo.online.provider.search.rocketmq.model.BaseMqSendModel;
//
//@Component("MusicToSolrConsumer")
//public class MusicToSolrConsumer implements PushMessage{
//	private static final Logger log = LoggerFactory.getLogger(MusicToSolrConsumer.class);
//	@Resource(name="SolrClient_music") 
//	private SolrClient solrClient_music;
//	@Resource(name="SolrClient_video") 
//	private SolrClient solrClient_video;
//	@Override
//	public void handleMessage(BaseMqSendModel baseMqSendModel) throws Exception {
//		log.info("Music消费开始....");
//		MusicInfo musicInfo = baseMqSendModel.getSendContentBean(MusicInfo.class);
//		Long videoId = musicInfo.getVideoId();
//		SolrDocument sdoc=null;
//		sdoc = solrClient_video.getById(videoId+"");
//		//重试10次
//		for(int i=0;i<10;i++){
//			if(sdoc==null){
//				Thread.sleep(5000);
//				sdoc = solrClient_video.getById(videoId+"");
//			}else{
//				break;
//			}
//		}
//		log.info("Music添加文档开始....");
//			//为文档添加域
//			List<SolrInputDocument> doc=new ArrayList<SolrInputDocument>();
//			// 4、为文档添加域
//			SolrInputDocument document = new SolrInputDocument();
//			document.addField("id", sdoc.get("id")+"");//视频id
//			document.addField("userId", sdoc.get("userId")+"");//用户id
//			document.addField("video", sdoc.get("video")+"");//视频地址
//			document.addField("cover", sdoc.get("cover")+"");//封面
//			document.addField("duration", sdoc.get("duration")+"");//封面
//			document.addField("href", sdoc.get("href")+"");//跳转地址
//			document.addField("type", sdoc.get("type")+"");//类型
//			document.addField("ads", sdoc.get("ads")+"");//是否是广告
//			document.addField("recommended", sdoc.get("recommended")+"");//推荐
//			document.addField("up", sdoc.get("up")+"");//点赞数量
//			document.addField("look", sdoc.get("look")+"");//观看数量
//			document.addField("comment", sdoc.get("comment")+"");//评论数量
//			document.addField("contentcount", sdoc.get("contentcount")+"");//评论内容
//			document.addField("titlename", sdoc.get("titlename")+"");//标题
//		    document.addField("id_music", musicInfo.getId()+"");//音乐id
//			document.addField("userId_music", musicInfo.getUserId()+"");//音乐用户id
//			document.addField("name_music", musicInfo.getName()+"");//音乐名
//			document.addField("category_music", musicInfo.getCategory()+"");
//			document.addField("cover_music", musicInfo.getCover()+"");
//			document.addField("recommended_music", musicInfo.getRecommended()+"");
//			document.addField("videoId_music", musicInfo.getVideoId()+"");
//			document.addField("used_music", musicInfo.getUsed()+"");
//			document.addField("type_music", musicInfo.getType()+"");
//			document.addField("music_music", musicInfo.getMusic()+"");
//			document.addField("createdTime_music", musicInfo.getCreatedTime()+"");
//			document.addField("nickname_user", sdoc.get("nickname_user")+"");
//			document.addField("avatar", sdoc.get("avatar")+"");
//			document.addField("height", sdoc.get("height")+"");
//			document.addField("width", sdoc.get("width")+"");
//			document.addField("share", sdoc.get("share")+"");
//			doc.add(document);
//			solrClient_video.add(doc);
//			// 5、向索引库中添加文档。
//			solrClient_video.commit();
//			log.info("Music消费结束进入索引库....");
//	}
//
//}
